package com.jiazhong.controller.safty;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import com.jiazhong.base.Constants;
import com.jiazhong.base.CurrUser;
import com.jiazhong.base.Result;
import com.jiazhong.service.safty.HomeService;
import com.jiazhong.view.MenuView;

@RestController
@RequestMapping("/safty/hmoe")
public class HomeController {
	@Autowired
	private HomeService homeService;
	@GetMapping("/getCurrUser")
	public CurrUser getCurrUser(HttpSession session) {
		CurrUser currUser = (CurrUser) session.getAttribute(Constants.SESSION_ATTR_CURRUSER);
		System.out.println(currUser+"===========");
		if(currUser!=null) {
			return currUser;
		}
		return null;
	}
	
	@GetMapping("/exit")
	public Result exit(HttpSession session) {
		session.removeAttribute(Constants.SESSION_ATTR_CURRUSER);
		return Result.success("您已退出");
	}
	@GetMapping("/menuList")
	public List<MenuView> menuList(String u_id){
		List<MenuView> menuList = homeService.menuList(u_id);
		return menuList;
	}

}
